{#<html>#}
{#<head>#}
{#    <meta charset="utf-8">#}
{#    <meta http-equiv="X-UA-Compatible" content="IE=edge">#}
{#    <meta name="viewport" content="width=device-width, initial-scale=1">#}
{#    <title>登陆页面</title>#}
{#    <!-- Bootstrap 核心 CSS 文件 -->#}
{#    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">#}
{#    <link rel="stylesheet" href="{{ buildStaticUrl('/plugins/bootstrap_v3/css/bootstrap.min.css') }}">#}
{#    <script src="{{ buildStaticUrl('/plugins/jquery.min.js') }}"></script>#}
{#    <script src="{{ buildStaticUrl('/plugins/bootstrap_v3/js/bootstrap.min.js') }}"></script>#}
{#    <script src="{{ buildStaticUrl('/plugins/layer/layer.js') }}"></script>#}
{#    <script src="{{ buildStaticUrl('/js/common.js') }}"></script>#}
{#    <script src="{{ buildStaticUrl('/js/member/login.js') }}"></script>#}
{##}
{#        <script src="//www.guanzhuoran.cn/static/plugins/jquery.min.js"></script>#}
    {#    <script src="//www.guanzhuoran.cn/static/plugins/bootstrap_v3/js/bootstrap.min.js"></script>#}
    {#    <script src="//www.guanzhuoran.cn/static/plugins/layer/layer.js"></script>#}
    {#    <script src="//www.guanzhuoran.cn/static/js/common.js"></script>#}
    {#    <script src="//0.0.0.0:5000/static/js/member/login.js"></script>#}
{#    <style>#}
{#        /*web background*/#}
{#        .container {#}
{#            display: table;#}
{#            height: 100%;#}
{#        }#}
{##}
{#        .row {#}
{#            display: table-cell;#}
{#            vertical-align: middle;#}
{#        }#}
{##}
{#        /* centered columns styles */#}
{#        .row-centered {#}
{#            text-align: center;#}
{#        }#}
{##}
{#        .col-centered {#}
{#            display: inline-block;#}
{#            float: none;#}
{#            text-align: left;#}
{#            margin-right: -4px;#}
{#        }#}
{#    </style>#}
{#</head>#}
{##}
{#<body>#}
{#<div class="container">#}
{#    <div class="row row-centered">#}
{#        <div class="well col-md-6 col-centered ">#}
{#            <h2 class="row-centered">{{ a }}</h2>#}
{#            <form:form action="/login" method="post" role="form" class="login_wrap">#}
{#                <div class="input-group input-group-lg" style="margin-top: 25px">#}
{#                    <span class="input-group-addon" id="sizing-addon1"><i class="glyphicon glyphicon-user"#}
{#                                                                          aria-hidden="true"></i></span>#}
{#                    <input type="text" class="form-control" id="login_name" name="login_name" placeholder="请输入用户ID"/>#}
{#                </div>#}
{#                <div class="input-group input-group-lg" style="margin-top: 20px">#}
{#                    <span class="input-group-addon" id="sizing-addon1"><i class="glyphicon glyphicon-lock"></i></span>#}
{#                    <input type="password" class="form-control" id="login_pwd" name="login_pwd" placeholder="请输入密码"/>#}
{#                </div>#}
{#                <br/>#}
{#                <button type="submit" class="btn btn-success btn-block do-login">登录</button>#}
{#                 <a class="btn btn-primary btn-block" href="{{ buildUrl('/member/reg') }}">注册</a>#}
{#            </form:form>#}
{#        </div>#}
{#        <footer class="text-center">#}
{#            晋ICP备2020013633号-1#}
{#        </footer>#}
{#    </div>#}
{#</div>#}
{#</body>#}
{#</html>#}

<!DOCTYPE html>
<meta charset="UTF-8">
<html>

<head>
    <title>H5微应用开发教学</title>
    <!-- 这个必须引入的啊，钉钉的前端js SDK, 使用框架的请自行参照开发文档 -->
    <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.7.13/dingtalk.open.js"></script>
    <!-- 这个jquery 想不想引入自己决定，没什么影响 -->
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>

<body>
<hr>
<h1>H5微应用免登教学</h1>
<p>当前页面的url:</p>
<p id="url"></p>
<br>
<p>解析url,获取的corpID:</p>
<p id="corpId"></p>
<br>
<p>SDK初始化获取的code:</p>
<p id="code"></p>
<br>
<p>请求我们服务端,登录返回的结果:{{ name }}</p>
<p id="result"></p>
</body>
<script type="text/javascript">
    $(function () {
        //钉钉sdk 初始化
        // dd.ready参数为回调函数，在环境准备就绪时触发，jsapi的调用需要保证在该回调函数触发后调用，否则无效。
        dd.ready(function () {
            //获取当前网页的url
            //http://ding-web.lnexin.cn/?corpid=ding46a9582af5b7541b35c2f4657eb6378f
            var currentUrl = document.location.toString()
            $("#url").append(currentUrl)

            // 解析url中包含的corpId
            var corpId = currentUrl.split("corpid=")[1];
            $("#corpId").append(corpId)

            //使用SDK 获取免登授权码
            dd.runtime.permission.requestAuthCode({
                corpId: corpId,
                onSuccess: function (result) {
                    var code = result.code;
                    $("#code").append(code)

                    //请求我们服务端的登陆地址
                    $.get("http://rsxz.rfnorthwest.com/ddd?code=" + code , function (response) {
                        // 我们服务器返回的信息
                        // 下面代码主要是将返回结果显示出来，可以根据自己的数据结构随便写
                        for (item in response) {
                            $("#result").append("<li>" + item + ":" + response[item] + "</li>")
                        }
                        if (response.user) {
                            for (item in response.user) {
                                $("#result").append("<li>\t[user 属性] " + item + " : " + response.user[item] + "</li>")
                            }
                        }
                    });
                }
            });
        });
    })

</script>

</html>
